import { RJSFSchema } from '@rjsf/utils';
import { TabsType } from './type';
import { DirectionType } from '@/components/DirectionField';

export const AssignDirection: RJSFSchema = {
  allOf: [
    {
      if: {
        properties: {
          Tabs: {
            const: TabsType.AssignDirection,
          },
        },
      },
      then: {
        properties: {
          Options: {
            type: 'object',
            title: '选项',
            properties: {
              direction: {
                title: '方向',
                type: 'array',
                default: [DirectionType.NormalToSource],
              },
              distance: {
                title: '距离',
                type: 'number',
                default: 1,
              },
              NumberOrSize: {
                type: 'string',
                title: '拉伸方式',
                default: 'quantity',
                oneOf: [
                  {
                    const: 'quantity',
                    title: '数量',
                  },
                  {
                    const: 'size',
                    title: '尺寸',
                  },
                ],
              },
            },
          },
        },
      },
    },
    {
      if: {
        properties: {
          Tabs: {
            const: TabsType.AssignDirection,
          },
          Options: {
            type: 'object',
            properties: {
              NumberOrSize: {
                const: 'quantity',
              },
            },
          },
        },
      },
      then: {
        properties: {
          Options: {
            type: 'object',
            properties: {
              count: {
                type: 'number',
                title: '数量',
              },
            },
          },
        },
      },
    },
    {
      if: {
        properties: {
          Options: {
            type: 'object',
            properties: {
              NumberOrSize: {
                const: 'size',
              },
            },
          },
        },
      },
      then: {
        properties: {
          Options: {
            type: 'object',
            properties: {
              size: {
                type: 'number',
                title: '尺寸',
              },
            },
          },
        },
      },
    },
  ],
};
